﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SpaceFight.Units.Steering;
using Microsoft.Xna.Framework;

namespace SpaceFight.Units
{
	class UnitController
	{
		List<IUnit> m_units = new List<IUnit>();
		SteeringOutput m_steeringOutput = new SteeringOutput();

		public void Add(IUnit p_unit)
		{
			m_units.Add(p_unit);
		}

		public void Update(GameTime p_gameTime)
		{
			foreach(var unit in m_units)
			{
				m_steeringOutput.Reset();
				
				// get the steering from the behavior
				SBColl.Behaviors[(int)unit.SteeringInfo.SteeringBehavior].GetSteering(unit, m_steeringOutput);
				
				// apply the steering to the unit
				unit.Update(p_gameTime, m_steeringOutput);
			}
		}
	}
}
